package main

import "fmt"

func defineSlice() {
	arr := []int{1, 2, 3, 4, 5, 6, 7, 8}
	sliceOne := arr[0:3]
	sliceTwo := arr[4:]
	fmt.Println(sliceOne, sliceTwo)
	fmt.Println(len(sliceOne), cap(sliceOne))
	fmt.Println(len(sliceTwo), cap(sliceTwo))
}
func makeSlice() {
	slice1 := make([]float32, 5, 9)
	fmt.Printf("len(slice1):%d,cap(slice1):%d", len(slice1), cap(slice1))
}

//复制切片
func copySlice() {
	var a = []int{1, 2, 3, 4, 5}
	var b = make([]int, 5, 10)
	copy(b, a)
	fmt.Println(b)
}

//删除切片中元素
func delEleInSlice() {
	var a = []int{1, 2, 3, 4, 5}
	//删除3
	a = append(a[:2], a[3:]...)
	fmt.Println(a)
}
func appendEle() {
	var a = make([]string, 5, 10)
	for i := 0; i < 10; i++ {
		a = append(a, fmt.Sprintf("%v", i))
	}
	fmt.Println(a)
}
func main() {
	appendEle()
}
